<?php
require_once('../smarty_admin.php');

$form = new Form_Thongtin();
$catalog_id = $_GET['catalog_id'];

$id = array_key_exists('thongtin_id',$_GET)?$_GET['thongtin_id']:0;

if (isset($_POST['Edit']))
{
	$form->process($_REQUEST);
	
	if (!$form->hasError()) 
		{
			header("Location: thongtin.php?catalog_id=$catalog_id");
			
		}


}else 
{
	
	if ($dbobject->query_exist("select * from thongtins where id = $id")) 
	{
		$object = $dbobject->query_object("select * from thongtins where id = $id");
		$form->title = $object->title;
		$form->sabo = $object->sabo;
		$form->content = $object->content;
		$form->img_name_alias = $object->img_name_alias;
		$form->active = $object->active;
		$form->date = $object->datetime;
		
	}
	else 
	{
	header("Location: thongtin.php?catalog_id=$catalog_id");
	}
}
$smarty->assign('form',$form);
$smarty->assign('Date_Month','2');
$smarty->display('thongtin/edit.tpl');
?>